package com.cy.pj.sys.service.impl;

import com.cy.pj.common.annotation.RequiredLog;
import com.cy.pj.sys.dao.SysLogDao;
import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.service.SysLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
public class SysLogServiceImpl implements SysLogService {
    private final SysLogDao sysLogDao;

    public SysLogServiceImpl(SysLogDao sysLogDao) {
        this.sysLogDao = sysLogDao;
    }

    @Override
    public void saveLog(SysLog sysLog) {
        sysLogDao.insertLog(sysLog);
    }

    @Transactional
    @Override
    public int deleteById(Long... ids) {
        int i = sysLogDao.deleteById(ids);
        return i;
    }

//    @Async
//    @RequiredAuthority(operation = "用户登录")
//    @RequiredTime(operation = "公告查询")
    @RequiredLog(operation = "公告查询")
    @Override
    public List<SysLog> findLogs(SysLog sysLog) {
        List<SysLog> list=sysLogDao.selectLogs(sysLog);
        return list;
    }

    @Override
    public SysLog findById(Long id) {
        SysLog log=sysLogDao.selectById(id);
        return log;
    }
}
